package com.dykj.fireFighting.web.controller;

import com.dykj.fireFighting.api.base.maintenance.service.IUrgentMaintenanceService;
import com.dykj.fireFighting.api.base.maintenance.vo.MaintenanceEvaluationVo;
import com.dykj.fireFighting.common.core.annotation.AutoLog;
import com.dykj.fireFighting.common.core.api.CommonResult;
import com.dykj.fireFighting.web.base.shiro.ShiroUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 紧急维保记录接口
 *
 * @Author hxb
 * @Date 2021-07-05 10:48:41
 */
@Slf4j
@Api(value = "维保机构评分", tags = {"维保机构评分"})
@RestController
@RequestMapping("/maintenance")
public class MaintenanceController {

    @DubboReference
    private IUrgentMaintenanceService urgentMaintenanceService;

    /**
     * 维保机构当月所有被服务的社会单位评价得分的平均值
     *
     * @param maintenanceDept
     * @return
     */
    @AutoLog(value = "维保机构当月评价得分的平均值")
    @ApiOperation(value = "维保机构当月评价得分的平均值", notes = "维保机构当月评价得分的平均值")
    @GetMapping("/queryMaintenanceEvaluationAvgList")
    public CommonResult<List<MaintenanceEvaluationVo>> queryMaintenanceEvaluationAvgList(String date, String maintenanceDept) {
        String unitId = ShiroUtil.getUser().getEnterpriseId().toString();
        List<MaintenanceEvaluationVo> maintenanceEvaluationVoList = urgentMaintenanceService.queryMaintenanceEvaluationAvgList(unitId, maintenanceDept, date);
        return CommonResult.success(maintenanceEvaluationVoList);
    }
}
